package com.screen.screendisplay.service.impl.ne;

import com.screen.screendisplay.entity.ne.NeProdoperSalesIncome;
import com.screen.screendisplay.mapper.ne.NeProdoperSalesIncomeMapper;
import com.screen.screendisplay.service.ne.NeProdoperSalesIncomeService;
import com.screen.screendisplay.vo.ne.NeSalesIncomeVO;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 新能源运营营收情况表 服务实现类
 * </p>
 *
 * @author xuesong
 * @since 2025-08-23
 */
@Service
public class NeProdoperSalesIncomeServiceImpl extends ServiceImpl<NeProdoperSalesIncomeMapper, NeProdoperSalesIncome> implements NeProdoperSalesIncomeService {

    @Autowired
    private NeProdoperSalesIncomeMapper neProdoperSalesIncomeMapper;

    @Override
    public List<NeSalesIncomeVO> getSalesIncome(Integer year) {
        List<NeProdoperSalesIncome> dataList = neProdoperSalesIncomeMapper.selectAnnualSalesIncomeData(5);
        
        return dataList.stream().map(data -> {
            NeSalesIncomeVO vo = new NeSalesIncomeVO();
            vo.setYear(data.getYear());
            vo.setTotalRevenue(data.getTotalRevenue());
            vo.setOperatingProfit(data.getOperatingProfit());
            return vo;
        }).collect(Collectors.toList());
    }
}
